<template>
    <div class="detail-box">
        <!-- 电影名称 -->
        <div class="film-name">{{details.filmName}}</div>
        <!-- 电影信息 stat-->
        <div class="film-info">
            <div class="film-tip">
                <div class="comment-count">
                    <div class="film-source">
                        <span class="star-img open"></span>
                        <span class="star-img open"></span>
                        <span class="star-img open"></span>
                        <span class="star-img close"></span>
                        <span class="star-img close"></span>
                        <span class="star-source">{{details.source}}</span>
                    </div>
                    <div class="star-count">93601短评</div>
                </div>
                <div class="film-desc">
                    <p>
                        <span>上映时间:</span>{{details.filmYear}}</p>
                    <p>
                        <span>电影类型:</span>{{details.filmTypes}}</p>
                    <p>
                        <span>参演明星:</span>{{details.castNames}}</p>
                </div>
            </div>
            <div class="film-img" :style="`background-image: url(${details.filmImg})`"></div>
        </div>
        <!-- 电影信息 end-->
        <!-- 电影简介 start -->
        <div class="film-plot">
            <div class="plot-title">剧情简介</div>
            <div class="plot-content">
                {{details.filmDesc}}
            </div>
        </div>
        <!-- 电影简介 end -->
        <!-- 演员列表 -->
        <div class="film-actor">
            <div class="actor-title">导演演员</div>
            <div class="actor-list">
                <div class="actor-item" v-for="(item, index) in getCastList" :key="index">
                    <div class="actor-img" :style="`background-image: url(${item.photo})`"></div>
                    <div class="actor-name">{{item.name}}</div>
                </div>
            </div>
        </div>
        <!-- 用户评论区 -->
        <div class="film-comments">
            <div class="comment-title">相关评论</div>
            <!-- <div class="comment-list">
                <film-comments v-for="(value,index) in comments" :key="index"></film-comments>
            </div> -->
            <FilmComment></FilmComment>
        </div>
    </div>
</template>
<script>
import FilmComment from "../components/filmComment";
export default {
    components: {
        FilmComment
    },
    data() {
        return {
            comments: [],
            details: {}
        };
    },
    computed: {
        getCastList() {
            if (this.details.castList) {
                return JSON.parse(this.details.castList);
            }
        }
    },
    methods: {
        getFilmDetail(id) {
            $.ajax({
                url: "http://localhost/film-project/filmApi/loadFilmById.php",
                data: {
                    filmId: id
                },
                dataType: "json",
                success: ({ result }) => {
                    this.details = result;
                    console.log(result);
                }
            });
        }
    },
    mounted() {
        // this.$nextTick(() => {
            this.getFilmDetail(this.$root.$children[0].filmId);//可以实现
            // this.getFilmDetail(this.$root.filmId);
        // });
    }
};
</script>
<style lang="less" scoped>
.detail-box {
    position: absolute;
    top: 0rem;
    bottom: @bottomHeight;
    left: 0rem;
    right: 0rem;
    overflow-y: auto;
}
// 详情页样式
.film-name {
    padding: 0.3rem;
    padding-bottom: 0rem;
    font-size: 0.38rem;
    color: @gray-dark;
}
.film-info {
    // css 新布局方式 grid 网格异形布局
    // 浏览器内核已做全面兼容
    color: @gray-dark;
    display: grid;
    grid-template-columns: 2fr 1fr;
    padding: 0rem 0.2rem 0.3rem 0.2rem;
    > .film-tip {
        grid-column-start: 1;
        grid-column-end: 2;
        > .comment-count {
            display: grid;
            grid-template-columns: 4fr 2fr;
            margin: 0.2rem 0rem;
            align-items: center;
            > .film-source {
                grid-column-start: 1;
                grid-column-end: 2;
            }
            > .star-count {
                grid-column-start: 2;
                grid-column-end: 3;
                font-size: 0.3rem;
            }
        }
        > .film-desc {
            font-size: 0.26rem;
            height: 2.4rem;
            overflow: hidden;
            padding-right: 0.2rem;
            line-height: 0.5rem;
            > p > span {
                color: @blue;
                padding-right: 0.1rem;
            }
        }
    }
    > .film-img {
        height: 3.4rem;
        background-repeat: no-repeat;
        background-size: cover;
        border-radius: 4%;
        background-color: @gray-light;
    }
}
.film-plot {
    color: @gray-dark;
    padding: 0rem 0.2rem 0.3rem 0.2rem;
    > .plot-title {
        font-size: 0.36rem;
        color: @gray;
        margin-bottom: 0.2rem;
    }
    > .plot-content {
        font-size: 0.24rem;
        text-indent: 0.56rem;
        line-height: 0.4rem;
    }
}
.film-actor {
    color: @gray-dark;
    padding-bottom: 0.3rem;
    font-size: 0rem;
    > .actor-title {
        font-size: 0.36rem;
        color: @gray;
        padding: 0rem 0.2rem;
        margin-bottom: 0.2rem;
    }
    .actor-list {
        white-space: nowrap;
        width: 100%;
        overflow-x: auto;
        &::after {
            content: "";
            width: 0.2rem;
            display: inline-block;
        }
        > .actor-item {
            width: 1.6rem;
            padding-left: 0.2rem;
            display: inline-block;
            vertical-align: top;
            > .actor-img {
                background-color: @gray-light;
                width: 1.6rem;
                height: 2.2rem;
                background-repeat: no-repeat;
                background-size: cover;
            }
            > .actor-name {
                white-space: pre-wrap;
                margin: 0.1rem 0rem;
                font-size: 0.24rem;
                text-align: center;
            }
        }
    }
}
</style>